// import upload from '@/utils/upload';
import request from '@/utils/request';

export function getFabricList(data) {
	return request({
		url: '/purchase/fabricInspectBill/list',
		method: 'get',
		data,
	});
}

export function updateFabric(data, type) {
	const params = {
		insertRecords: [],
		removeRecords: [],
		updateRecords: [],
	};
	if (type === 'add') {
		params.insertRecords = [data];
	} else if (type === 'edit') {
		params.updateRecords = [data];
	} else {
		params.removeRecords = [data];
	}
	return request({
		url: '/purchase/fabricInspectBill/add',
		method: 'post',
		data: params,
	});
}

export const getRegularFabricList = () => {
	return request({
		url: '/purchase/materialbill/regularFabric/list',
		method: 'get',
	});
};

export const getBoundProductList = () => {
	return request({
		url: '/MPurchase/fabric/bound/product/list',
		method: 'get',
	});
};

// 面料入库
export const addInbound = (data) => {
	return request({
		url: '/MPurchase/fabric/inbound/add',
		method: 'post',
		data,
	});
};

export const getInboundList = (data) => {
	return request({
		url: `/MPurchase/fabric/inbound/list`,
		method: 'get',
		data,
	});
};

export const deleteFabric = (id) => {
	return request({
		url: `/MPurchase/fabric/${id}`,
		method: 'delete',
	});
};

export const editInbound = (data) => {
	return request({
		url: `/MPurchase/fabric/inbound/edit`,
		method: 'put',
		data,
	});
};

export const addOutbound = (data) => {
	return request({
		url: '/MPurchase/fabric/outbound/add',
		method: 'post',
		data,
	});
};

export const getOutboundList = (data) => {
	return request({
		url: `/MPurchase/fabric/outbound/list`,
		method: 'get',
		data,
	});
};

export const editOutbound = (data) => {
	return request({
		url: `/MPurchase/fabric/outbound/edit`,
		method: 'put',
		data,
	});
};

export const getInspectList = (productName) => {
	return request({
		url: '/MPurchase/fabric/inspect/list',
		method: 'get',
		data: {
			productName
		}
	});
};

export const getBoundSummary = (data) => {
	return request({
		url: '/MPurchase/fabric/bound/summary',
		method: 'get',
		data
	})
}

export const getRecordBillProduct = (data) => {
	return request({
		url: '/purchase/fabricRecordBill/product/list',
		method: 'post',
		data
	})
}

export const getInsCodeList = (productName, bottlesResult, insCode, readColorResult) => {
	return request({
		url: '/purchase/fabricRecordBill/fabric/insCode/list',
		method: 'get',
		data: {
			productName,
			bottlesResult,
			insCode,
			readColorResult
		}
	})
}

export const getFileName = () => {
	return request({
		url: '/purchase/warehousebill/export',
		method: 'get',
		data: {
			pageNum: 1,
			pageSize: 100
		}
	})
}

//裁剪铺布列表查询
export function getCuttingLayingFabricList(data) {
	return request({
		url: '/cuttingLayingFabric/list',
		method: 'get',
		data,
	});
}
//裁剪铺布删除
export const deleteCuttingLayingFabric = (id) => {
	return request({
		url: `/cuttingLayingFabric/delete/${id}`,
		method: 'delete',
	});
};
//裁剪铺布修改
export const editCuttingLayingFabric = (data) => {
	return request({
		url: `/cuttingLayingFabric/edit`,
		method: 'put',
		data,
	});
};

export const getLayingInfoById = (id) =>{
	return request({
		url: `/cuttingLayingFabric/info/${id}`,
		method: 'get',
	});
}

export const getInspectCodeList = (data) =>{
	return request({
		url: `/purchase/fabricRecordBill/cabinet/insCode/list`,
		method: 'get',
		data,
	});
}
